// mine.js
var wxMarkerData = [];
// 自定义标签
var iconPath = "../../images/icons/"
var app = getApp();
var tabs1 = [
    {
        "icon": iconPath + "attend.png",
        "iconActive": iconPath + "attend.png",
        "title": "签到",
        "extraStyle": "border:none;",
    },
    {
        "icon": iconPath + "daily.png",
        "iconActive": iconPath + "daily.png",
        "title": "日志",
        "extraStyle": "border:none;",
    },
    {
        "icon": iconPath + "schedule.png",
        "iconActive": iconPath + "schedule.png",
        "title": "我的工作",
        "extraStyle": "border:none;",
    },
    {
        "icon": iconPath + "project.png",
        "iconActive": iconPath + "project.png",
        "title": "项目",
        "extraStyle": "border:none;",
    },
]

var tabs2 = [
    {
        "icon": iconPath + "approve.png",
        "iconActive": iconPath + "approve.png",
        "title": "申请",
        "extraStyle": "border:none;",
    },
    {
        "icon": iconPath + "phone.png",
        "iconActive": iconPath + "phone.png",
        "title": "通讯录",
        "extraStyle": "border:none;",
    },
    {
        "icon": iconPath + "home.png",
        "iconActive": iconPath + "home.png",
        "title": "东华之家",
        "extraStyle": "border:none;",
    },
    {
        "icon": iconPath + "tally.png",
        "iconActive": iconPath + "tally.png",
        "title": "记账",
        "extraStyle": "border:none",
    }
]

var userInfo = {
    avatar: "https://pic4.zhimg.com/e515adf3b_xl.jpg",
    nickname: "小闹钟",
    sex: "♂",  // 0, male; 1, female
    meta: '1篇日记',
}

var SERVER_URL=app.globalData.SERVER_URL;
Page({
    // data
    data: {
        // 展示的tab标签
        listData: [],
        scale: '15',
        Height: '0',
        controls: '40',
        latitude: '',
        longitude: '',
        markers: [],
        placeData: {},
        captchaImage: '',
        show: "",
        tabs1: tabs1,
        tabs2: tabs2,
        // 当前选中的标签
        currentTab1: "tab1",
        currentTab2: "tab5",

        // 高亮的标签索引
        highLightIndex: "0",

        // 模态对话框样式
        modalShowStyle: "",

        // 待新建的日记标题
        diaryTitle: "",

        // TODO 用户信息
        userInfo: userInfo,

        list: [
            {
                id: 'api',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '微信登录',
                        url: 'login/login'
                    }, {
                        zh: '获取用户信息',
                        url: 'get-user-info/get-user-info'
                    }, {
                        zh: '发起支付',
                        url: 'request-payment/request-payment'
                    }, {
                        zh: '分享',
                        url: 'share/share'
                    }, {
                        zh: '客服消息',
                        url: 'custom-message/custom-message'
                    }, {
                        zh: '模板消息',
                        url: 'template-message/template-message'
                    }
                ]
            },{
                id: 'page',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '设置界面标题',
                        url: 'set-navigation-bar-title/set-navigation-bar-title'
                    }, {
                        zh: '标题栏加载动画',
                        url: 'navigation-bar-loading/navigation-bar-loading'
                    }, {
                        zh: '页面跳转',
                        url: 'navigator/navigator'
                    }, {
                        zh: '下拉刷新',
                        url: 'pull-down-refresh/pull-down-refresh'
                    }, {
                        zh: '创建动画',
                        url: 'animation/animation'
                    }, {
                        zh: '创建绘画',
                        url: 'canvas/canvas'
                    }, {
                        zh: '显示操作菜单',
                        url: 'action-sheet/action-sheet'
                    }, {
                        zh: '显示模态弹窗',
                        url: 'modal/modal'
                    }, {
                        zh: '显示消息提示框',
                        url: 'toast/toast'
                    }
                ]
            },{
                id: 'page',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '设置界面标题',
                        url: 'set-navigation-bar-title/set-navigation-bar-title'
                    }, {
                        zh: '标题栏加载动画',
                        url: 'navigation-bar-loading/navigation-bar-loading'
                    }, {
                        zh: '页面跳转',
                        url: 'navigator/navigator'
                    }, {
                        zh: '下拉刷新',
                        url: 'pull-down-refresh/pull-down-refresh'
                    }, {
                        zh: '创建动画',
                        url: 'animation/animation'
                    }, {
                        zh: '创建绘画',
                        url: 'canvas/canvas'
                    }, {
                        zh: '显示操作菜单',
                        url: 'action-sheet/action-sheet'
                    }, {
                        zh: '显示模态弹窗',
                        url: 'modal/modal'
                    }, {
                        zh: '显示消息提示框',
                        url: 'toast/toast'
                    }
                ]
            },{
                id: 'page',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '设置界面标题',
                        url: 'set-navigation-bar-title/set-navigation-bar-title'
                    }, {
                        zh: '标题栏加载动画',
                        url: 'navigation-bar-loading/navigation-bar-loading'
                    }, {
                        zh: '页面跳转',
                        url: 'navigator/navigator'
                    }, {
                        zh: '下拉刷新',
                        url: 'pull-down-refresh/pull-down-refresh'
                    }, {
                        zh: '创建动画',
                        url: 'animation/animation'
                    }, {
                        zh: '创建绘画',
                        url: 'canvas/canvas'
                    }, {
                        zh: '显示操作菜单',
                        url: 'action-sheet/action-sheet'
                    }, {
                        zh: '显示模态弹窗',
                        url: 'modal/modal'
                    }, {
                        zh: '显示消息提示框',
                        url: 'toast/toast'
                    }
                ]
            },{
                id: 'page',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '设置界面标题',
                        url: 'set-navigation-bar-title/set-navigation-bar-title'
                    }, {
                        zh: '标题栏加载动画',
                        url: 'navigation-bar-loading/navigation-bar-loading'
                    }, {
                        zh: '页面跳转',
                        url: 'navigator/navigator'
                    }, {
                        zh: '下拉刷新',
                        url: 'pull-down-refresh/pull-down-refresh'
                    }, {
                        zh: '创建动画',
                        url: 'animation/animation'
                    }, {
                        zh: '创建绘画',
                        url: 'canvas/canvas'
                    }, {
                        zh: '显示操作菜单',
                        url: 'action-sheet/action-sheet'
                    }, {
                        zh: '显示模态弹窗',
                        url: 'modal/modal'
                    }, {
                        zh: '显示消息提示框',
                        url: 'toast/toast'
                    }
                ]
            },{
                id: 'page',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '设置界面标题',
                        url: 'set-navigation-bar-title/set-navigation-bar-title'
                    }, {
                        zh: '标题栏加载动画',
                        url: 'navigation-bar-loading/navigation-bar-loading'
                    }, {
                        zh: '页面跳转',
                        url: 'navigator/navigator'
                    }, {
                        zh: '下拉刷新',
                        url: 'pull-down-refresh/pull-down-refresh'
                    }, {
                        zh: '创建动画',
                        url: 'animation/animation'
                    }, {
                        zh: '创建绘画',
                        url: 'canvas/canvas'
                    }, {
                        zh: '显示操作菜单',
                        url: 'action-sheet/action-sheet'
                    }, {
                        zh: '显示模态弹窗',
                        url: 'modal/modal'
                    }, {
                        zh: '显示消息提示框',
                        url: 'toast/toast'
                    }
                ]
            },{
                id: 'page',
                name: '生日提醒',
                open: false,
                pages: [
                    {
                        zh: '设置界面标题',
                        url: 'set-navigation-bar-title/set-navigation-bar-title'
                    }, {
                        zh: '标题栏加载动画',
                        url: 'navigation-bar-loading/navigation-bar-loading'
                    }, {
                        zh: '页面跳转',
                        url: 'navigator/navigator'
                    }, {
                        zh: '下拉刷新',
                        url: 'pull-down-refresh/pull-down-refresh'
                    }, {
                        zh: '创建动画',
                        url: 'animation/animation'
                    }, {
                        zh: '创建绘画',
                        url: 'canvas/canvas'
                    }, {
                        zh: '显示操作菜单',
                        url: 'action-sheet/action-sheet'
                    }, {
                        zh: '显示模态弹窗',
                        url: 'modal/modal'
                    }, {
                        zh: '显示消息提示框',
                        url: 'toast/toast'
                    }
                ]
            },{
                id: 'network',
                name: '东华之家上线了',
                open: false,
                pages: [
                    {
                        zh: '发起一个请求',
                        url: 'request/request'
                    }, {
                        zh: 'WebSocket',
                        url: 'web-socket/web-socket'
                    }, {
                        zh: '上传文件',
                        url: 'upload-file/upload-file'
                    }, {
                        zh: '下载文件',
                        url: 'download-file/download-file'
                    }
                ]
            }
        ]
    },
    makertap: function (e) {
        var that = this;
        var id = e.markerId;
        that.showSearchInfo(wxMarkerData, id);
        that.changeMarkerColor(wxMarkerData, id);
    },
    onReady: function (e) {
        // 使用 wx.createMapContext 获取 map 上下文
        this.mapCtx = wx.createMapContext('myMap')
    },
    scannew: function (e) {
        var openId = wx.getStorageSync('openId');
        wx.request({
            url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/sign/scannew',
            data: {
                "key": app.globalData.key,
                "openId": openId,
                "NoticeNum": e.currentTarget.dataset.title,
            },
            method: 'POST',
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
                wx.navigateTo({
                    url: '/pages/detail/newdetail?noticenum='+e.currentTarget.dataset.title,
                })
            },
            fail: function () {
                console.log("请求失败");
            },
            complete: function () {
                console.log("请求完成");
            }
        })
    },
    start: function () {
        wx.getStorage({
            key: 'flag',
            success: function (res) {
                console.log(res.data);
            }
        })
        wx.setStorage({
            key: 'flag',
            data: 1
        })
        var that = this;
        var openId = wx.getStorageSync('openId');
        wx.request({
            url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/sign/isOpenId',  //根据经纬度转换成具体地址
            data: {
                "key": app.globalData.key,
                "openId": openId,
            },
            method: 'POST',
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
                setTimeout(function () {
                        if (res.data.isOpenId == 1) {
                            wx.navigateTo({
                                url: '/pages/new/new',
                            })
                        } else {
                            wx.navigateTo({
                                url: '/pages/login',
                            })
                        }
                    }
                )
            },
            fail: function () {
                // fail
                console.log("请求失败");
            },
            complete: function () {
                // complete
                console.log("请求完成");
            }
        })
    },
    onLoad: function () {
        var that = this;

        /*{
         "id": 1,
         "placeName": "合肥",
         "placeImageUrl": "",
         "placeOpenTime": 1505854800,
         "placeCloseTime": 1505919600,
         "placeAddress": "合肥",
         "placeLongitude": "117.192616",
         "placeLatitude": "31.825643"
         }*/

        wx.request({
            url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/sign/getAddressInfo',
            data: {
                "key": app.globalData.key,
            },
            method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
            success: function (res) {
                console.log(res.data.address)
                that.setData({
                    //listData:res.data.address
                })
            },
            fail: function () {
                // fail
            },
            complete: function () {
                // complete
            }
        })

        that.setData({
            url: app.globalData.url
        })

        var data = JSON.stringify({
            page: 1,
            pageSize: 10,
            request: {
                placeLongitude: app.globalData.longitude,
                placeLatitude: app.globalData.latitude,
                userId: app.globalData.userId
            }
        })

        /*wx.getLocation({
         type: 'wgs84', //返回可以用于wx.openLocation的经纬度
         success: (res) => {
         that.setData({
         markers: that.getSchoolMarkers(),
         scale: 12,
         longitude: res.longitude,
         latitude: res.latitude
         })
         }
         });*/

        wx.getSystemInfo({
            success: function (res) {
                //设置map高度，根据当前设备宽高满屏显示
                that.setData({
                    view: {
                        Height: res.windowHeight
                    },

                })
            }
        })
    },
    controltap(e) {
        this.moveToLocation()
    },
    getSchoolMarkers() {

        var market = [];

        for (let item of this.data.listData) {

            let marker1 = this.createMarker(item);

            market.push(marker1)
        }
        return market;
    },
    moveToLocation: function () {
        this.mapCtx.moveToLocation()
    },
    strSub: function (a) {
        var str = a.split(".")[1];
        str = str.substring(0, str.length - 1)
        return a.split(".")[0] + '.' + str;
    },
    createMarker(point) {

        let latitude = this.strSub(point.placeLatitude);
        let longitude = point.placeLongitude;
        let marker = {
            /*iconPath: "../../image/banner5.jpeg",*/
            id: point.id || 0,
            name: point.placeName || '',
            title: point.placeName || '',
            latitude: latitude,
            longitude: longitude,
            label: {
                x: -24,
                y: -26,
                content: point.placeName
            },
            width: 30,
            height: 30
        };
        return marker;
    },
    //加载
    onLoad: function () {
        var that = this;
        var openId = wx.getStorageSync('openId');
        this.setLocation();
        wx.request({
            url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/column/index',  //统计信息
            data: {
                "key": app.globalData.key,
                openId:openId
            },
            method: 'GET',
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
                let result = res.data;
                if (result && result.code==0) {
                    that.setData({
                        'check': result.data.approve,
                        'account': result.data.account,
                        'newscount': result.data.newscount
                    });
                }
            },
            fail: function () {
                console.log("请求失败");
            },
            complete: function () {
                console.log("请求完成");
            }
        })
    },
    setLocation:function(){
        var that = this;
        var openId = wx.getStorageSync('openId');
        let url = "/tongbu/tbattend";
        url = SERVER_URL+url;
        wx.getLocation({
            type: 'gcj02', // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
            success: function (res) {
                var locationString = res.latitude + "," + res.longitude;   //获取的经度纬度
                wx.request({
                    url: url,  //根据经纬度转换成具体地址
                    data: {
                        "key": app.globalData.key,
                        "openId": openId,
                        "location": locationString
                    },
                    method: 'POST',
                    header: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    }, // 设置请求的 header
                    // header: {},
                    success: function (res) {
                        console.log(res);
                        //if (res.data.result.address!==undefined){
                        //    that.setData({
                        //        'task.address': res.data.result.address,
                        //        'task.province': res.data.result.address_component.province,
                        //        'task.city': res.data.result.address_component.city,
                        //        'task.state': res.data.result.address_component.district
                        //    })
                        //}

                    },
                    fail: function () {
                        // fail
                        console.log("请求失败");
                    },
                    complete: function () {
                        // complete
                        console.log("请求完成");
                    }
                });
                wx.request({
                    url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/sign/task',  //根据经纬度转换成具体地址
                    data: {
                        "key": app.globalData.key,
                        "openId": openId,
                    },
                    method: 'POST',
                    header: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    success: function (res) {
                        that.setData({
                            'button.txt': '签到',
                        });
                        if (res.data.data.endTime !== undefined && res.data.data.endTime !== null) {
                            var endTimes = ' 签退时间 ' + res.data.data.endTime;
                            that.setData({
                                'button.txt': res.data.data.buttonTxt,
                                'qtsj':endTimes,
                                'qtsjvalue':res.data.data.endTime
                            });
                        }
                        if (res.data.data.startTime !== undefined && res.data.data.startTime !== null) {
                            var startTimes = ' 签到时间 ' + res.data.data.startTime;
                            that.setData({
                                'button.txt': res.data.data.buttonTxt,
                                'qdsj':startTimes,
                                'qdsjvalue': res.data.data.startTime
                            });
                        }
                        if (res.data.project !== undefined && res.data.project !== null) {
                            app.globalData.projectArr = res.data.project;
                            that.setData({
                                array: res.data.project
                            });
                        }
                        if (res.data.data.remark !== undefined && res.data.data.remark !== null) {
                            that.setData({
                                'task.remark': res.data.data.remark
                            });
                        }
                        if (res.data.data.qdaddress !== undefined && res.data.data.qdaddress !== null) {
                            that.setData({
                                'task.qdaddress': res.data.data.qdaddress
                            });
                        }
                        if (res.data.data.qtaddress !== undefined && res.data.data.qtaddress !== null) {
                            that.setData({
                                'task.qtaddress': res.data.data.qtaddress
                            });
                        }
                        that.setData({
                            creating: res.data.data.creating
                        });
                    },
                    fail: function () {
                        // fail
                        console.log("请求失败");
                    },
                    complete: function () {
                        // complete
                        console.log("请求完成");
                    }
                })
            },
            fail: function () {
                // fail
                console.log("定位失败");
            },
            complete: function () {
                // complete
                console.log("定位完成");
            }
        })
    },
    showSearchInfo: function (data, i) {
        var that = this;
        that.setData({
            placeData: {
                title: '名称：' + data[i].title + '\n',
                address: '地址：' + data[i].address + '\n',
                telephone: '电话：' + data[i].telephone
            }
        });
    },
    changeMarkerColor: function (data, id) {
        var that = this;
        var markersTemp = [];
        for (var i = 0; i < data.length; i++) {
            if (i === id) {
                data[i].iconPath = "../../img/marker_yellow.png";
            } else {
                data[i].iconPath = "../../img/marker_red.png";
            }
            markersTemp[i] = data[i];
        }
        that.setData({
            markers: markersTemp
        });
    },
    kindToggle: function (e) {
        var id = e.currentTarget.id, list = this.data.list;
        for (var i = 0, len = list.length; i < len; ++i) {
            if (list[i].id == id) {
                if (list[i].url) {
                    wx.navigateTo({
                        url: 'pages/' + list[i].url
                    })
                    return
                }
                list[i].open = !list[i].open
            } else {
                list[i].open = false
            }
        }
        this.setData({
            list: list
        });
    },
    imgclick: function () {
        var that = this;
        var show;
        wx.scanCode({
            success: (res) => {
                this.show = "--result:" + res.result + "--scanType:" + res.scanType + "--charSet:" + res.charSet + "--path:" + res.path;
                var str = res.result.split("&");
                var id = str[0].split("=");
                var placeName = str[1].split("=");
                var placeImageUrl = str[2].split("=");
                var placeOpenTime = str[3].split("=");
                var placeCloseTime = str[4].split("=");
                var placeAddress = str[5].split("=");
                var placeLongitude = str[6].split("=");
                var placeLatitude = str[7].split("=");
                that.setData({
                    show: this.show,
                    listData: [
                        {
                            "id": id[1],
                            "placeName": placeName[1],
                            "placeImageUrl": placeImageUrl[1],
                            "placeOpenTime": placeOpenTime[1],
                            "placeCloseTime": placeCloseTime[1],
                            "placeAddress": placeAddress[1],
                            "placeLongitude": placeLongitude[1],
                            "placeLatitude": placeLatitude[1]
                        }]
                })
                /*wx.showToast({
                 title: '成功',
                 icon: 'success',
                 duration: 2000
                 })*/
                this.mapCtx = wx.createMapContext('myMap')
                that.setData({
                    url: app.globalData.url
                })
                var data = JSON.stringify({
                    page: 1,
                    pageSize: 10,
                    request: {
                        placeLongitude: app.globalData.longitude,
                        placeLatitude: app.globalData.latitude,
                        userId: app.globalData.userId
                    }
                })

                wx.getLocation({
                    type: 'gcj02', //返回可以用于wx.openLocation的经纬度
                    success: (res) => {
                        /*that.setData({
                         markers: that.getSchoolMarkers(),
                         scale: 12,
                         longitude: placeLongitude[1],
                         latitude: placeLatitude[1]
                         })*/

                        wx.navigateTo({
                            //url: '../search/search?id=' + id[1] + '&placeName=' + placeName[1] + '&longitude=' + placeLongitude[1] + '&latitude=' + placeLatitude[1]
                            url:'../search/go'
                        });

                    }
                });

                wx.getSystemInfo({
                    success: function (res) {
                        //设置map高度，根据当前设备宽高满屏显示
                        that.setData({
                            view: {
                                Height: res.windowHeight
                            },

                        })
                    }
                })
            },
            fail: (res) => {
                wx.showToast({
                    title: '失败',
                    icon: 'success',
                    duration: 2000
                })
            },
            complete: (res) => {
            }
        })
    },
// 隐藏模态框
    hideModal() {
        this.setData({modalShowStyle: ""});
    },

// 清除日记标题
    clearTitle() {
        this.setData({diaryTitle: ""});
    },

    onShow: function() {
        this.hideModal();
        this.clearTitle();
    },

// 点击tab项事件
    touchTab1: function(event){
        var tabIndex = parseInt(event.currentTarget.id);
        var template = "tab" + (tabIndex + 1).toString();
        this.setData({
                currentTab1: template,
                highLightIndex: tabIndex.toString(),
            }
        );
        wx.getStorage({
            key: 'flag',
            success: function (res) {
                console.log(res.data);
            }
        })
        wx.setStorage({
            key: 'flag',
            data: 1
        })
        /*var that = this;
         var openId = wx.getStorageSync('openId');
         wx.request({
         url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/sign/isOpenId',  //根据经纬度转换成具体地址
         data: {
         "openId": openId,
         },
         method: 'POST',
         header: {
         "Content-Type": "application/x-www-form-urlencoded"
         },
         success: function (res) {
         setTimeout(function () {
         if (res.data.isOpenId == 1) {*/
        if (tabIndex=='0'){
            wx.navigateTo({
                url: '/pages/new/new',
            });
        }
        else if(tabIndex =='1'){
            wx.navigateTo({
                url: '/pages/lists/task/index',
            });
        }
        else if(tabIndex =='2'){
            wx.navigateTo({
                url: '/pages/lists/work/index',
            });
        }
        else if(tabIndex =='3'){
            wx.navigateTo({
                url: '/pages/lists/project/index',
            });
        }
        else {
            wx.showToast({
                title: '正在开发中',
                icon: 'loading',
                duration: 1000
            });
        }
        /*} else {
         wx.navigateTo({
         url: '/pages/login',
         })
         }
         }
         )
         },
         fail: function () {
         // fail
         console.log("请求失败");
         },
         complete: function () {
         // complete
         console.log("请求完成");
         }
         })*/
    },

    touchTab2: function (event) {
        var tabIndex = parseInt(event.currentTarget.id);
        var template = "tab" + (tabIndex + 1).toString();
        this.setData({
                currentTab2: template,
                highLightIndex: tabIndex.toString(),
            }
        );
        wx.getStorage({
            key: 'flag',
            success: function (res) {
                console.log(res.data);
            }
        })
        wx.setStorage({
            key: 'flag',
            data: 2
        });
        /*var tabIndex = parseInt(event.currentTarget.id);
         var template = "tab" + (tabIndex + 1).toString();
         this.setData({
         currentTab2: template,
         highLightIndex: tabIndex.toString(),
         }
         );
         wx.getStorage({
         key: 'flag',
         success: function (res) {
         console.log(res.data);
         }
         })
         wx.setStorage({
         key: 'flag',
         data: 1
         })
         var that = this;
         var openId = wx.getStorageSync('openId');
         wx.request({
         url: 'https://xcx.ahdhst.cn/tp/public/index.php/Index/sign/isOpenId',  //根据经纬度转换成具体地址
         data: {
         "openId": openId,
         },
         method: 'POST',
         header: {
         "Content-Type": "application/x-www-form-urlencoded"
         },
         success: function (res) {
         setTimeout(function () {
         /*if (res.data.isOpenId == 1) {
         wx.navigateTo({
         url: '/pages/new/new',
         })
         } else {
         wx.navigateTo({
         url: '/pages/login',
         })
         }*/
        /*wx.navigateTo({
         url: '/pages/public/public'
         })
         }
         )
         },
         fail: function () {
         // fail
         console.log("请求失败");
         },
         complete: function () {
         // complete
         console.log("请求完成");
         }
         })*/
        if (tabIndex=='4'){
            wx.navigateTo({
                url: '/pages/lists/check/index',
            })
        }
        if (tabIndex=='5'){
            wx.navigateTo({
                url: '/pages/lists/tel/index',
            })
        }
        if (tabIndex=='6'){
            wx.navigateTo({
                url: '/pages/lists/home/index',
            })
        }
        else if(tabIndex =='7'){
            wx.navigateTo({
                url: '/pages/lists/logs/add/index',
            })
        }
    },

// 点击新建日记按钮
    touchAdd: function (event) {
        this.setData({
            modalShowStyle: "opacity:1;pointer-events:auto;"
        })
    },

// 新建日记
    touchAddNew: function(event) {
        this.hideModal();

        wx.navigateTo({
            url: "../new/new?title=" + this.data.diaryTitle,
        });
    },

// 取消标题输入
    touchCancel: function(event) {
        this.hideModal();
        this.clearTitle();
    },

// 标题输入事件
    titleInput: function(event) {
        this.setData({
            diaryTitle: event.detail.value,
        })
    },
    myCheck_click:function(){
        wx.navigateTo({
            url: './check/index',
        });
    },
    account_click:function(){
        wx.navigateTo({
            url: './account/index',
        });
    },
    news_click:function(){
        wx.navigateTo({
            url: './news/index',
        });
    },
});
